<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>用户登录</title>
    <% include("./layout/css.html"){} %>
    <link rel="stylesheet" href="${ctxPath}/assets/css/login.css"/>
    <script>
        if (window != top)
            top.location.replace(location.href);
    </script>
</head>
<body>
<div class="login-wrapper">

    <div class="login-header">
        <img src="${ctxPath}/assets/images/logo.png"> EasyWeb
    </div>

    <div class=" login-body">
        <div class="layui-card">
            <div class="layui-card-header">
                <i class="layui-icon layui-icon-engine"></i>&nbsp;&nbsp;用户登录
            </div>
            <form class="layui-card-body layui-form layui-form-pane">
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-username"></i></label>
                    <div class="layui-input-block">
                        <input name="username" type="text" class="layui-input" placeholder="账号"
                               lay-verType="tips" lay-verify="required" required/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-password"></i></label>
                    <div class="layui-input-block">
                        <input name="password" type="password" class="layui-input" placeholder="密码"
                               lay-verType="tips" lay-verify="required" required/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-vercode"></i></label>
                    <div class="layui-input-block">
                        <div class="layui-row inline-block">
                            <div class="layui-col-xs7">
                                <input name="code" type="text" class="layui-input" placeholder="验证码"
                                       autocomplete="off" lay-verType="tips" lay-verify="required" required/>
                            </div>
                            <div class="layui-col-xs5" style="padding-left: 10px;">
                                <img class="login-captcha" src="${ctxPath }/assets/captcha">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <a class="layui-link">帐号注册</a>
                    <a class="layui-link pull-right">忘记密码？</a>
                </div>
                <div class="layui-form-item">
                    <button lay-filter="loginSubmit" class="layui-btn layui-btn-fluid" lay-submit>登 录</button>
                </div>
                <div class="layui-form-item login-other">
                    <label>第三方登录</label>
                    <a href="javascript:;"><i class="layui-icon layui-icon-login-qq"></i></a>
                    <a href="javascript:;"><i class="layui-icon layui-icon-login-wechat"></i></a>
                    <a href="javascript:;"><i class="layui-icon layui-icon-login-weibo"></i></a>
                </div>
            </form>
        </div>
    </div>

    <div class="login-footer">
        <p>© 2019 <a href="https://easyweb.vip" target="_blank">EasyWeb版权所有</a></p>
        <p>
            <span><a href="https://easyweb.vip" target="_blank">前往github</a></span>
            <span><a href="https://easyweb.vip" target="_blank">前往gitee</a></span>
            <span><a href="https://easyweb.vip" target="_blank">文档说明</a></span>
        </p>
    </div>
</div>

<!--  js部分 -->
<% include("./layout/js.html"){} %>
<script>
    layui.use(['layer', 'form', 'index'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var index = layui.index;

        // layer.open({
        //     type: 1,
        //     title: false,
        //     shade: 0,
        //     offset: '30px',
        //     content: '<div style="padding: 15px;">演示系统账号：admin  密码：admin</div>'
        // });

        // 表单提交
        form.on('submit(loginSubmit)', function (obj) {
            layer.load(2);
            $.post('login', obj.field, function (res) {
                if (200 == res.code) {
                    layer.msg('登录成功', {icon: 1, time: 1500}, function () {
                        index.clearTabCache();
                        location.replace('./');
                    });
                } else {
                    layer.closeAll('loading');
                    layer.msg(res.msg, {icon: 5});
                    // $('.login-captcha').trigger('click');
                }
            }, 'JSON');
            return false;
        });

        // 图形验证码
        $('.login-captcha').click(function () {
            this.src = this.src + '?t=' + (new Date).getTime();
        });
    });
</script>
</body>
</html>
